package com.project.controller;

import com.project.pojo.Result;
import com.project.service.AccountService;
import jakarta.validation.constraints.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController 
@RequestMapping("/user")
@Validated
public class AccountController {
    @Autowired
    private AccountService accountService;

    @PostMapping("/register")
    public Result register(@Pattern(regexp = "^\\S{5,16}$") String username, @Pattern(regexp = "^\\S{5,16}") String password, Integer type) {
        accountService.register(username, password, type);
        return Result.success();
    }

}
